package com.jp.knowledge.view.maintab;

import android.content.Context;
import android.view.View;

import com.jp.knowledge.R;

/**
 * Created by 528787067@qq.com on 2017/7/20.
 */

public class MainTab4 extends MainTab1 {

	private boolean isSelected;
	private int selectIconId;
	private int unselectIconId;

	public MainTab4(Context context) {
		super(context);
	}

	@Override
	protected void init() {
		super.init();
		setLoginState(false);
	}

	@Override
	public void selectState() {
		isSelected = true;
		tabIcon.setImageResource(selectIconId);
		tabTitle.setTextColor(getContext().getResources().getColor(R.color.theme_color));
	}

	@Override
	public void unselectState() {
		isSelected = false;
		tabIcon.setImageResource(unselectIconId);
		tabTitle.setTextColor(getContext().getResources().getColor(R.color.font_gray_deep));
	}

	public void setLoginState(boolean loginState){
		tabTitle.setText(loginState ? "我的" : "未登录");
		selectIconId = loginState ? R.mipmap.bottombar_my_blue : R.mipmap.bottombar_my_unlogin_blue;
		unselectIconId = loginState ? R.mipmap.bottombar_my : R.mipmap.bottombar_my_unlogin;
		if(isSelected)
			selectState();
		else
			unselectState();
	}

	public void hasMessage(boolean hasMessage){
		tabRemindDot.setVisibility(hasMessage ? View.VISIBLE : View.GONE);
	}
}
